home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 July / Ahoy_Magazine_85-07_1985_Double_L.d64 / fast song loader (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  3KB  |  120 lines

  1. 0 print"[147]":poke53280,9:poke53281,7:poke646,9
  2. 1 print "               song loader":print:print
  3. 3 print"   this is an example of how to load    and use a song stored on disk";
  4. 5 print" using the program song maker."
  5. 6 rem
  6. 7 print"   line 10 and line 9000 must execute    before anything else in your";
  7. 8 print " program."
  8. 10 gosub 9000:goto 80
  9. 60 for ph=0 to es%:for n=1 to len(md$(ph)):sys mm
  10. 62 f$=fr$(n,ph)
  11. 65 sys m
  12. 67 for i=0 to du%(val(mid$(md$(ph),n,1))):next
  13. 68 rem sys mm:rem staccato notes
  14. 69 next:next
  15. 70 sys mm:return
  16. 80 print "[144]when song ends, press":print:print "shift to repeat song"
  17. 85 print "or q to quit"
  18. 100 if peek(653)<>0 then gosub 60:goto 100
  19. 110 if peek(203)=62 then poke 198,0:sys 65126
  20. 190 goto 100
  21. 8997 rem
  22. 8998 rem set up sound and load song
  23. 8999 rem
  24. 9000 f$="f":i=0:n=0:vc=0:m=848:mm=823:rem m & mm put ml in cassette buffer
  25. 9001 ph=0:dim g%(2),ad(2),du%(9),ak%(2),dy%(2),sn%(2),re%(2),wf%(2),pw%(2,1)
  26. 9007 rem
  27. 9008 rem open song file & get # of phrases and # of voices
  28. 9009 rem
  29. 9010 open 2,8,2,"0:song #1,s,r"
  30. 9015 input#2,es%,ev%,ld%
  31. 9017 rem
  32. 9018 rem dimension key variables
  33. 9019 rem
  34. 9020 dim fr$(ld%,es%),md$(es%)
  35. 9027 rem
  36. 9028 rem load the remainder of the variables from the song file
  37. 9029 rem
  38. 9030 for i=0 to 2:input#2,g%(i):next
  39. 9031 for i=0 to 2:input#2,ak%(i),dy%(i),sn%(i),re%(i)
  40. 9032 for n=0 to 1:input#2,pw%(i,n):next:next
  41. 9033 for i=0 to 9:input#2,du%(i):next
  42. 9034 for ph=0 to es%:input#2,md$(ph):for n=1 to len(md$(ph))
  43. 9035 for i=1 to 6:get#2,a$,b$
  44. 9036 if a$="" then a$=chr$(0)
  45. 9037 fr$(n,ph)=fr$(n,ph)+a$:next:next:next
  46. 9040 close 2
  47. 9041 rem
  48. 9042 rem set up envelopes
  49. 9043 rem
  50. 9044 for i=0 to 2:ad(i)=54277+7*i:next
  51. 9045 for i=0 to 2:poke ad(i),ak%(i) or dy%(i)
  52. 9046 poke ad(i)+1,sn%(i) or re%(i):next
  53. 9047 rem
  54. 9048 rem set pulse widths
  55. 9049 rem
  56. 9050 for i=0 to 2:vc=54274+i*7:for n=0 to 1
  57. 9051 poke vc+n,pw%(i,n):next:next
  58. 9066 rem
  59. 9067 rem set filter and volume
  60. 9068 rem filter frequency
  61. 9069 rem low byte (0-7) x%; high byte (0-255) y%
  62. 9070 x%=3:y%=150
  63. 9071 poke 54293,x%:poke 54294,y%
  64. 9072 rem filter on?
  65. 9073 rem voice 1 on=1; 2 on=2; 3 on=4; 1&2 on=3; 2&3 on=6; all on=7
  66. 9074 x%=0
  67. 9075 rem filter resonance
  68. 9076 rem peak volume (0=low, 15=high)
  69. 9077 y%=14
  70. 9078 y%=y%*16:poke 54295,x% or y%
  71. 9079 rem select filter type
  72. 9080 rem low-pass=1;band-pass=2;high-pass=4;lo-band=3;hi-band=6;all=7
  73. 9081 x%=1
  74. 9082 x%=x%*16
  75. 9083 rem
  76. 9084 rem select overall volume
  77. 9085 rem 15=high, 0=low
  78. 9086 y%=15
  79. 9087 poke 54296,x% or y%
  80. 9197 rem
  81. 9198 rem machine language routine at m
  82. 9199 rem
  83. 9218 rem find address of f$ and put it in zero page at 139, 140
  84. 9219 rem
  85. 9220 n=peek(45)+256*peek(46)+3:y%=n/256:x%=n-y%*256
  86. 9221 poke m,173:poke m+1,x%:poke m+2,y%:n=n+1:y%=n/256:x%=n-y%*256
  87. 9222 poke m+3,133:poke m+4,251:poke m+5,173:poke m+6,x%:poke m+7,y%
  88. 9223 poke m+8,133:poke m+9,252:poke m+10,160:poke m+11,0
  89. 9224 poke m+12,162:poke m+13,0
  90. 9228 rem
  91. 9229 rem get each pitch from f$ and put it in frequency register
  92. 9230 for i=m+14 to m+54 step 8:poke i,177:poke i+1,251
  93. 9231 poke i+2,157:poke i+3,0:poke i+4,212
  94. 9232 poke i+5,200:poke i+6,162:read a:poke i+7,a:next
  95. 9233 data 1,7,8,14,15,4
  96. 9238 rem
  97. 9239 rem gate each sound open
  98. 9240 n=0:for i=m+59 to m+71 step 6
  99. 9241 poke i,173:a=mm-3+n:y%=a/256:x%=a-256*y%:poke i+1,x%:poke i+2,y%
  100. 9242 poke i+3,141:read a:poke i+4,a:poke i+5,212:n=n+1:next
  101. 9243 data 4,11,18
  102. 9247 rem
  103. 9248 rem garbage collection
  104. 9250 for i=m+77 to m+90:read a:poke i,a:next
  105. 9255 data 164,52,165,51,105,6,144,1,200,133,51,132,52,96
  106. 9257 rem
  107. 9258 rem gate-off ml routine at mm
  108. 9259 rem
  109. 9260 for i=mm to mm+16 step 8
  110. 9261 poke i,173:y%=3:x%=34+(i-mm)/8:poke i+1,x%:poke i+2,y%:rem uses 820-822
  111. 9262 poke i+3,41:poke i+4,254
  112. 9263 poke i+5,141:read a:poke i+6,a:poke i+7,212:next:poke mm+24,96
  113. 9264 data 4,11,18
  114. 9267 rem
  115. 9268 rem set waveforms with gates off
  116. 9269 rem stored at 820-822--line 9261 requires this (820=hex 03 34)
  117. 9270 poke 820,g%(0):poke 821,g%(1):poke 822,g%(2):sys mm
  118. 9280 ph=0
  119. 9290 return
  120.